package com.company.sendemo.basics.awThreads.databaseclash;

import java.util.Arrays;

public class ThreadShare {
    static char[] a = {'-','-','-','-','-'};

    static char c = '*';

    public static void main(String[] args) {

        Thread t1 = new Thread() {
            @Override
            public void run() {
                while(true) {
                    for (int i = 0; i < a.length; i++) {
                        a[i] = c;
                    }
                    c = (c=='*'?'-':'*');
                    System.out.println(Arrays.toString(a));
                }
            }
        };

        Thread t2 = new Thread() {
            @Override
            public void run() {
                while(true) {
                    System.out.println(Arrays.toString(a));
                    //toString() 方法返回此对象本身（它已经是一个字符串）。
                }
            }
        };
        t1.start();
        t2.start();

    }

}
